home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions Momentum component
-
- #include "NSDLL.h"
-
- /*****************************/
- /* Gradient search procedure */
-
- __declspec(dllexport) void performMomentum(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *weights, // Pointer to the vector of weights
- int length, // Length of the weight vector
- NSFloat *gradient, // Pointer to the vector of gradients, one for each weight
- NSFloat *step, // Pointer to the learning rate/s
- BOOL individual, // Indicates whether their is one learning rate for all weights (FALSE),
- // or each weight has its own learning rate
- NSFloat momentum, // Momentum rate for all weights
- NSFloat *delta // Last weight Update
- )
- {
- register int i;
-
- for (i=0; i<length; i++)
- weights[i] += delta[i] = momentum*delta[i] + step[individual?i:0]*gradient[i];
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocMomentum(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int length, // Length of the weight vector
- BOOL individual // Indicates whether their is one learning rate for all weights (FALSE),
- // or each weight has its own learning rate
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeMomentum(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */
-